<%@ page language="java" contentType="text/html;charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import="com.yuxin.common.util.CollectionUtils" %>
<%@ page import="com.yuxin.common.util.DBUtil" %>
<%@ page import="com.yuxin.common.util.StringUtils" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.yuxin.common.util.*" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/meta.jsp"%>
<title>${site_title}</title>
<%
Connection conn = DBUtil.getConnection();
String sql = "SELECT * FROM P_NOTE WHERE 1=1 AND TYPE='1' ORDER BY UPDATE_TIME DESC";
try{
	List<Map<String,Object>> datas = DBUtil.queryList(conn,sql);
	request.setAttribute("datas", datas);
}catch(Exception e){
	e.printStackTrace();
}
%>
</head>
<body>
	<%@ include file="/header.jsp"%>
	<div class="container">
		<div class="row-fluid">
			<%@ include file="menu.jsp"%>
			<div class="span9">
				<div class="span12 subpage-title">
					<div class="left">
						<h4 id="headertext" class="title">快讯管理</h4>
					</div>
					<div class="right">
						<a href="${ctx}/admin/message_a.jsp">
							<button class="btn btn-success" onclick="do_add()">
								<i class="icon icon-plus icon-white"></i> 新增
							</button>
						</a>
					</div>
				</div>
				<table id="message_list" class="table table-bordered" style="border: 1px solid #CCC;">
					<thead>
						<tr>
							<th></th>
							<th>快讯</th>
							<th style="width:30%">发布时间</th>
							<th style="width:10%">操作</th>
						</tr>
					</thead>
					<tbody>
					<c:forEach var="item" items="${datas}" varStatus="st">
						<tr id="row${item.ID}">
							<td>
								${st.index+1}
							</td>
							<td>
							<ul class="thumbnails">
							  <li class="span3">
							    <div class="thumbnail">
							      <img src="${ctx}${item.IMG}" />
							    </div>
							  </li>
							  <li  class="span5">
							  	<h5><a href="#">${item.TITLE}</a></h5>
							  </li>
							</ul>
							</td>
							<td>
								<fmt:formatDate value="${item.CREATE_TIME}" pattern="yyyy-MM-dd HH:mm:ss"/>
							</td>
							<td>
								<a href="${ctx}/admin/message_a.jsp?ID=${item.ID}">修改</a><br><br>
								<a href="#" onclick="deleteMessage(this,'${item.ID}')">删除</a>
							</td>
						</tr>
					</c:forEach>
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<script>
		$(document).ready(function() {
			$("#menu_message").addClass("active");
		});
	</script>
	<%@ include file="/footer.jsp"%>
</body>
</html>
<script>
//商品上架
function deleteMessage(ele,id){
    $(ele).addClass("disabled");
    $.post("${ctx}/admin/message_action.jsp",{action:"delete","ID":id},function(data){
    	$(ele).removeClass("disabled");
        if(data.isSuccess){
            $.pnotify({
                title: '消息提示',
                text: '操作成功!',
                type: 'success',
                animation: 'fade',
                shadow: false,
                delay: 1000
            });
            $("#row"+id).remove();
        }else{
            $.pnotify({
                title: '消息提示',
                text: '操作失败：'+data.error,
                type: 'error',
                animation: 'fade',
                hide:false,
                shadow: false
            });
        }
    });
}
</script>